﻿using Warehouse.Infrastructure;

namespace Warehouse.Read.Api
{
    public static class DependencyInjection
    {
        public static void AddSqlSugarContext(this IServiceCollection services, IConfiguration configuration)
        {
            // 注册 SqlSugar 客户端
            services.AddScoped(provider =>
            {
                var sugarDBContext = provider.GetRequiredService<MyContext>();
                return sugarDBContext.InitDBContext("DefaultConnection"); // 默认连接字符串名称
            });

            

            // 注册 SugarDBContext
            services.AddScoped(provider => new MyContext(configuration));
        }
    }
}
